package com.qf.servlet;

import com.qf.pojo.DtsTopic;
import com.qf.service.DtsTopicService;
import com.qf.util.ResponseUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

/**
 * @author Ypl
 * @version V1.0
 * @Project September-mavens
 * @Package com.qf.servlet
 * @Description:
 * @Date 2022/10/21 17:29
 */
@RestController
@SuppressWarnings("all")
@RequestMapping("/admin/topic")
public class AdminTopicController {
    @Autowired
    DtsTopicService dtsTopicService;

    /**
     * 专题分页查询
     * 业务分析：
     *  1.
     */
    @GetMapping("/list")
    public Object list(@RequestParam(value = "page",defaultValue = "1") Integer page,
                       @RequestParam(value = "limit",defaultValue = "20")Integer limit,
                       @RequestParam(value = "sort",defaultValue = "add_time")String sort,
                       @RequestParam(value = "order",defaultValue = "desc") String order,
                       String title,String subtitle){

        Map <String,Object> data  = dtsTopicService.findByPage(page,limit,order,sort,title,subtitle);
        return ResponseUtil.ok(data);
    }

    /**
     * 专题添加
     */
    @RequestMapping("/create")
    public Object insert(@RequestBody DtsTopic dtsTopic){

        dtsTopicService.insert(dtsTopic);

        return ResponseUtil.ok(dtsTopic);

    }
    /**
     * 专题修改
     */
    @PostMapping("/update")
    public Object update(@RequestBody DtsTopic dtsTopic){

        dtsTopicService.update(dtsTopic);
        return ResponseUtil.ok(dtsTopic);
    }

    /**
     * 专题删除
     */
    @PostMapping("/delete")
    public  Object delete(@RequestBody DtsTopic dtsTopic){
        dtsTopicService.delete(dtsTopic);
        return ResponseUtil.ok();
    }
}
